package com.cskaoyan.exceptionJY;

import com.cskaoyan.model.vo.BaseRespVo;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class SystemExceptionHandler {
    @ExceptionHandler(NameRepeatException.class)
    public BaseRespVo nameRepeatException(){
        return BaseRespVo.error(602,"管理员已经存在");
    }

    @ExceptionHandler(RoleExistException.class)
    public BaseRespVo roleExistException(){
        return BaseRespVo.error(640, "当前角色存在管理员，不能删除");
    }

    @ExceptionHandler(WrongPasswordException.class)
    public BaseRespVo wrongPasswordException(){
        return BaseRespVo.error(605,"用户名或密码不正确");
    }

    @ExceptionHandler(AuthorizationException.class)
    public BaseRespVo authorizationException(){
        return BaseRespVo.error(506, "无操作权限");
    }

    @ExceptionHandler(UsernameRepeatException.class)
    public BaseRespVo usernameRepeatException(){
        return BaseRespVo.error(602, "该手机号已注册，请直接登录");
    }

    @ExceptionHandler(CodeErrorException.class)
    public BaseRespVo codeErrorException(){
        return BaseRespVo.error(703, "验证码不正确，请重新输入");
    }

    @ExceptionHandler(PhoneNumberException.class)
    public BaseRespVo phoneNumberException(){
        return BaseRespVo.error(402, "手机号输入错误，请检查你的手机号");
    }

    @ExceptionHandler(PhoneNumberNotExitsException.class)
    public BaseRespVo phoneNumberNotExitsException(){
        return BaseRespVo.error(402, "手机号未注册，请先注册");
    }
}
